package com.uek.service;

import com.uek.mapper.BaseDictMapper;
import com.uek.mapper.CstCustomerDetailMapper;
import com.uek.mapper.CstCustomerMapper;
import com.uek.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService{
    @Autowired
    BaseDictMapper baseDictMapper;
    @Autowired
    CstCustomerMapper cstCustomerMapper;

    @Override
    public List<BaseDict> getBaseDict(String type) {
        BaseDictExample baseDictExample= new BaseDictExample();
        BaseDictExample.Criteria criteria = baseDictExample.createCriteria();
        criteria.andDictTypeNameEqualTo(type);

        List<BaseDict> baseDicts = baseDictMapper.selectByExample(baseDictExample);
        return baseDicts;
    }

    @Override
    public int addCustomer(CstCustomer cstCustomer) {
        int i = cstCustomerMapper.insert(cstCustomer);
        return i;
    }
   @Autowired
    CstCustomerDetailMapper cstCustomerDetailMapper;

    @Override
    public int addCustomerDetail(CstCustomerDetail cstCustomerDetail) {
        int i1 = cstCustomerDetailMapper.insert(cstCustomerDetail);
        return i1;
    }

    @Override
    public List<CstCustomer> getAllCstCustmoer() {
        /*将对象new出来然后能进行调用*/
        CstCustomerExample cstCustomerExample =new CstCustomerExample();
        CstCustomerExample.Criteria criteria = cstCustomerExample.createCriteria();
       /*加上一个条件*/
        criteria.getAllCriteria();
        List<CstCustomer> cstCustomers = cstCustomerMapper.selectByExample(cstCustomerExample);
        return cstCustomers;
    }
}
